package com.rzico.sbl.ui.home

import com.rzico.sbl.R
import com.rzico.sbl.databinding.ActivityMarketGroupEditBinding
import com.rzico.sbl.model.CommonData
import com.xinnuo.common.extend.visibleValue
import com.xinnuo.common.view.FullyLinearLayoutManager
import com.xinnuo.common_ui.base.BaseActivity
import com.xinnuo.slimadapter.SlimAdapter

class MarketGroupEditActivity : BaseActivity(R.layout.activity_market_group_edit) {

    private val mBinding by lazy { ActivityMarketGroupEditBinding.bind(getRootView()) }

    override fun initData() {
        initTitle(title = "活动编辑", name = "保存")

        initLayout()

        repeat(10) {
            mList += CommonData(it.toString())
        }

        mAdapter.setDataList(mList)
    }

    private fun initLayout() {
        mBinding
            .groupList
            .apply {
                isNestedScrollingEnabled = false
                layoutManager = FullyLinearLayoutManager(getIContext())

                mAdapter = SlimAdapter.creator()
                    .register<CommonData>(R.layout.item_market_group_edit) { jector, bean, index ->
                        jector.apply {
                            visibility(
                                R.id.item_group_divider,
                                visibleValue { index < mList.size - 1 }
                            )
                        }
                    }
                    .attachTo(this)
            }
    }

    override fun initListener() {
    }

}